<script type="text/javascript"
	src="<?php echo $this->baseUrl();?>/js/jquery.rating.js"></script>
<script type="text/javascript">
jQuery(function(){
    jQuery('form.rating').rating();
});
</script>

<script>
$('#enviar').live('click',function() {

	$.post($('#new-comment').attr("action"), $('#new-comment').serialize(),function () {
	
		var url = "/products/view-product?product=<?php echo $this->info[0]['id_product']?>";

		$.get(url, function(data) {
			$("#messages-for").html($(data).find("#messages-for").html());
			jQuery('form.rating').rating();
		});	
	});
});

</script>
<div id="list-products">
	<div style="display: inline-block;" id="prod">
		<div id="view">
			<div style="text-align: center;">
				<span class="title"><?php echo $this->info[0]['name']?> </span>
			</div>
			<div class="image" style="float: left;">
				<div>
					<img src="<?php echo $this->info[0]['image']?>" width="300"
						height="300" alt="<?php echo $this->info[0]['name']?>">
				</div>

				<div>
					Avaliação do produto:
					<div class="rating" style="float: right;"
						title="<?php if($this->rate == 0){echo 'Nenhuma avaliação para o produto';}else{ echo "Nota do produto: "; if($this->rate > 5){echo '5';}else{echo $this->rate;} }?>">
						<div class="star" <?php if($this->rate >= 1):?>
							style="background-position: 0 -16px;" <?php endif;?>></div>
						<div class="star" <?php if($this->rate >= 2):?>
							style="background-position: 0 -16px;" <?php endif;?>></div>
						<div class="star" <?php if($this->rate >= 3):?>
							style="background-position: 0 -16px;" <?php endif;?>></div>
						<div class="star" <?php if($this->rate >= 4):?>
							style="background-position: 0 -16px;" <?php endif;?>></div>
						<div class="star" <?php if($this->rate >= 5):?>
							style="background-position: 0 -16px;" <?php endif;?>></div>
					</div>
					<div>
						<label style="color: #800"><?php echo sizeof($this->rates); if(sizeof($this->rates) == 1) {echo ' voto';} else { echo ' votos';}?>
						</label>
					</div>
				</div>

				<div class="options">
				<?php if($this->info[0]['status'] == 1 && $this->info[0]['quantity'] > 0):?>
					<div style="float: left;">
						<label style="color: maroon;">R$</label><label class="price"><?php echo $this->info[0]['price'] ?>
						</label>
					</div>
					<div style="float: right;">
						<a style="cursor: pointer;"
							onclick="addToCart('/cart/add-cart/idProduct/<?php echo $this->info[0]['id_product']?>')"><img
							alt="" src="../images/button_in_cart.gif"
							style="float: right; margin-bottom: 5px"> </a>
					</div>
				<?php else:?>
				<div style="float: left;">
					<font style="color: maroon; font-size: 15pt; margin-left: 10px;">Produto
					indisponível no momento</font>
				</div>
				<?php endif;?>
				</div>
			</div>

			<div style="float: left;">
				<div class="description">
					<p align="justify" class="description">
					<?php echo $this->description ?>
					</p>
				</div>
			</div>
		</div>
		<div class="for-messages" id="messages-for">
			<div>
				<span class="title">Comentários</span>
			</div>
			<?php if($this->user):?>
			<!-- <div style="height: 80px;">
				<form enctype="multipart/form-data" id="new-comment" class="form"
					action="../message/send-comment" method="post">
					<div class="image"
						style="width: 60px; height: 60px; float: left; background: #FFF">
						<img style="width: 60px; height: 60px;"
							src="<?php if(file_exists("../public/img/p".$this->user['idClient'].'/'.md5($this->user['idClient']) . ".jpg")){ echo "../img/p".$this->user['idClient'].'/'.md5($this->user['idClient']) . ".jpg"; }else{ echo "../images/profile.png";} ?>">
						<input type="hidden"
							value="<?php echo $this->info[0]['id_product']?>"
							id="comment-product" name="comment-product"> <input type="hidden"
							value="<?php echo $this->user['idClient']?>" id="comment-client"
							name="comment-client">
					</div>
					<textarea style="width: 480px; float: left;" maxlenght="500"
						id="comment" name="comment"
						placeholder="O que achou do produto <?php echo $this->user['name'] ?>?"></textarea>
					<input style="float: right;" class="send-buttom" id="enviar"
						name="enviar" type="button" value="Comentar">
				</form>
			</div> -->
			
			<div style="height: 30px;">
			<?php if($this->rateByUser):?>
			
				<div style="float: left;">
					<span style="float: left;">Sua avaliação:</span>
				</div>
				<div class="rating" style="float: left;"
					title="<?php if($this->rateByUser == 0){echo 'Nenhuma avaliação para o produto';}else{ echo "Nota do produto: "; if($this->rate > 5){echo '5';}else{echo $this->rate;} }?>">
					<div class="star" <?php if($this->rateByUser >= 1):?>
						style="background-position: 0 -16px;" <?php endif;?>></div>
					<div class="star" <?php if($this->rateByUser >= 2):?>
						style="background-position: 0 -16px;" <?php endif;?>></div>
					<div class="star" <?php if($this->rateByUser >= 3):?>
						style="background-position: 0 -16px;" <?php endif;?>></div>
					<div class="star" <?php if($this->rateByUser >= 4):?>
						style="background-position: 0 -16px;" <?php endif;?>></div>
					<div class="star" <?php if($this->rateByUser >= 5):?>
						style="background-position: 0 -16px;" <?php endif;?>></div>
				</div>
			<?php else:?>
				<div style="float: left;">
					<span style="float: left;">Avalie o produto:</span>
				</div>
				<div style="float: left;">
					<form style="display: none" title="Average Rating: <?=$r?>"
						class="rating" action="/products/rate-product">
						<input type="hidden" name="valor" value="1" /> <select
							style="float: left">
							<option value="1/<?php echo $this->rateByUser?>">1</option>
							<option value="2/<?php echo $this->rateByUser?>">2</option>
							<option value="3/<?php echo $this->rateByUser?>">3</option>
							<option value="4/<?php echo $this->rateByUser?>">4</option>
							<option value="5/<?php echo $this->rateByUser?>">5</option>
						</select>
					</form>
				</div>
				
			<?php endif;?>
				<div style="float: left;" class="fb-like" data-href="http://carmezin.com.br/products/view-product?product=<?php echo $this->info[0]['id_product']?>" data-send="true" data-layout="button_count" data-width="450" data-show-faces="true"></div>
				<div style="float: left; margin-left: 5px;"><a href="http://twitter.com/share" class="twitter-share-button" data-count="none" data-via="LojaMirianMartins" rel="nofollow">Tweet</a><script type="text/javascript" src="http://platform.twitter.com/widgets.js"></script></div>
			</div>
			<?php endif;?>

			<?php $i = 0;?>
			<!--<?php if($this->comments):?>
			<?php foreach ($this->comments as $comment):?>
			<div id="comments" style="width: 700px; height: 90px; margin-top: 10px; <?php if($i == 0 || $i % 2 == 0):?> background: #F1F1F1; <?php else:?> background: #9B7B7B; <?php endif;?>">

				<div class="image"
					style="float: left; margin-left: 15px; margin-top: 15px; margin-right: 15px; width: 60px; height: 60px;">
					<img style="width: 60px; height: 60px;"
						src="<?php if(file_exists("../public/img/p".$comment['id_client'].'/'.md5($comment['id_client']) . ".jpg")){ echo "../img/p".$comment['id_client'].'/'.md5($comment['id_client']) . ".jpg"; }else{ echo "../images/profile.png";} ?>">
				</div>

				<div class="comment" style="max-width: 730px; float: left;">
					<b><?php echo $comment['username']?>: </b>
					<?php echo $comment['comment']?>
				</div>

				<div class="posted"
					style="float: right; padding-top: 35px; padding-right: 15px;">
					<?php
					$date_time  = new DateTime(date("Y-m-d H:i:s"));

					$nDias = $date_time->diff( new DateTime($comment['date']));

					if($nDias->format('%i') < 1 && $nDias->format('%y') < 1 && $nDias->format('%m') < 1){
						echo "Postado agora mesmo";
					}

					if($nDias->format('%y') > 0){

						if($nDias->format('%y') > 1){
							echo "Postado a ".$nDias->format('%y')." anos";
						}
						else{
							echo "Postado a ".$nDias->format('%y')." ano";
						}
					}

					else if($nDias->format('%m') > 0){

						if($nDias->format('%m') > 1){
							echo "Postado a ".$nDias->format('%m')." meses";
						}
						else{
							echo "Postado a ".$nDias->format('%m')." mês";
						}
					}

					else if($nDias->format('%d') > 0){

						if($nDias->format('%d') > 1){
							echo "Postado a ".$nDias->format('%d')." dias";
						}
						else{
							echo "Postado a ".$nDias->format('%d')." dia";
						}
					}

					else if($nDias->format('%h') > 0){

						if($nDias->format('%h') > 1){
							echo "Postado a ".$nDias->format('%h')." horas";
						}
						else{
							echo "Postado a ".$nDias->format('%h')." hora";
						}
					}

					else if($nDias->format('%i') > 0){

						if($nDias->format('%i') > 1){
							echo "Postado a ".$nDias->format('%i')." minutos";
						}
						else{
							echo "Postado a ".$nDias->format('%i')." minuto";
						}
					}
					?>
				</div>
			</div>
			<?php $i = $i + 1;?>
			<?php endforeach;?>
			<?php else:?>
			<div class="nothing">Nenhum comentário para o produto.</div>
			<?php endif;?>-->
			<div class="fb-comments" data-href="http://carmezin.com.br/products/view-product?product=<?php echo $this->info[0]['id_product']?>" data-width="670" data-num-posts="10"></div>
		</div>
	</div>

	<div class="random">
		<div
			style="width: 200px; text-align: center; background: #800; border: 1px solid #800; margin-top: -46px;">
			Confira Também</div>
			<?php foreach ($this->random as $menu):?>
		<a
			href="/products/view-product?product=<?php echo $menu['id_product']?>">
			<div style="width: 200px; height: 200px; border: 1px solid #800;"
				title="<?php echo $menu['name']?>">
				<img style="width: 200px; height: 200px;" alt=""
					src="<?php echo $menu['image']?>">
			</div> </a>
			<?php endforeach;?>
	</div>
	<div class="clear"></div>
</div>
